package com.web;

import com.pojo.dto.Message;
import com.pojo.entity.CArticle;
import com.pojo.vo.ArticleVo;
import com.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;


import java.util.List;

@RestController
public class ArticleController {

    @Autowired
    ArticleService articleService;

    @RequestMapping(value = "article/getAll", method = RequestMethod.POST)
    public Message<List<ArticleVo>> getAllArticle(ArticleVo articleVo) {
        return articleService.getAllArticle(articleVo);
    }
    @RequestMapping(value = "article/getArticlesByid", method = RequestMethod.POST)
    public Message<List<ArticleVo>> getArticlesById(Long id) {
        return articleService.getArticlesById(id);
    }

    @RequestMapping(value = "article/getArticleByid", method = RequestMethod.POST)
    public Message<ArticleVo> getArticleById(ArticleVo articleVo) {
        return articleService.getArticle(articleVo);
    }
    @RequestMapping(value = "article/addArticle", method = RequestMethod.POST)
    public Message<String> addArticle(ArticleVo article) {
        return articleService.addArticle(article);
    }

    @RequestMapping(value = "article/updateArticle", method = RequestMethod.POST)
    public Message<ArticleVo> updateArticle(ArticleVo article) {
        return articleService.updateArticle(article);
    }
    @RequestMapping(value = "article/deleteArticle", method = RequestMethod.POST)
    public Message<String> deleteArticle(Long id) {
        return articleService.deleteArticleById(id);
    }

}
